package org.greyhawk.samonitor.vo;

import org.greyhawk.samonitor.domain.ResourcesType;

public class CollectForm {
	
	private final static int MAX_RESULT = 5;
	
	private Long siteId;
	
	private Long channelId;
	
	private String type;
	
	private String status;
	
	private Integer currPage = 1;
	
	private Long resCount;
	
	private Long totalPage;

	public Long getTotalPage() {
		if(getResCount() % MAX_RESULT == 0)
			return getResCount() / MAX_RESULT;
		return getResCount() / MAX_RESULT + 1;
	}

	public Long getSiteId() {
		return siteId;
	}

	public void setSiteId(Long siteId) {
		this.siteId = siteId;
	}

	public Long getChannelId() {
		return channelId;
	}

	public void setChannelId(Long channelId) {
		this.channelId = channelId;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	
	
	public Long getQuerySiteId(){
		if(getChannelId() == -1)
			return getSiteId();
		else
			return getChannelId();
	}
	
	public ResourcesType getResourcesType(){
		return ResourcesType.valueOf(getType());
	}
	
	public AdvertStatus getAdvertStatus(){
		return AdvertStatus.valueOf(getStatus());
	}
	
	
	@Override
	public String toString() {
		// TODO Auto-generated method stub
		StringBuffer buffer = new StringBuffer();
		buffer.append(getSiteId());
		buffer.append(":");
		buffer.append(getChannelId());
		buffer.append(":");
		buffer.append(getType());
		buffer.append(":");
		buffer.append(getStatus());
		return buffer.toString();
	}

	public Integer getCurrPage() {
		return currPage;
	}

	public void setCurrPage(Integer currPage) {
		this.currPage = currPage;
	}

	public Long getResCount() {
		return resCount;
	}

	public void setResCount(Long resCount) {
		this.resCount = resCount;
	}
	
	public Integer getFirstResult(){
		 return (getCurrPage() - 1)*MAX_RESULT;
	}
	
	public Integer getMaxResult(){
		return getCurrPage()*MAX_RESULT;
	}
	
	

}
